/*
 * Copyright (C) hushenglan
 */

#ifndef _MYNET_POLL_H_
#define _MYNET_POLL_H_

namespace mynet
{

class CEvent;

class CPoll
{

public:

    /*
     * 构造函数
     */
    CPoll();

    /*
     * 析构函数
     */
    virtual ~CPoll();

    /*
     * 创建事件模型
     */
    virtual bool create() = 0;

    /*
     * 等待事件
     */
    virtual int waitForEvents(int timeout) = 0;

    /*
     * 获取事件
     */
    virtual CEvent* getEvent(int index) = 0;

    /*
     * 判断是否监听了此event
     */
    virtual bool ifInReadEvent(CEvent* event) = 0;
    virtual bool ifInWriteEvent(CEvent* event) = 0;
    virtual bool ifInErrorEvent(CEvent* event) = 0;

    /*
     * 将此event加入监听
     */
    virtual void insertReadEvent(CEvent* event) = 0;
    virtual void insertWriteEvent(CEvent* event) = 0;
    virtual void insertErrorEvent(CEvent* event) = 0;

    /*
     * 不再监听此event
     */
    virtual void removeReadEvent(CEvent* event) = 0;
    virtual void removeWriteEvent(CEvent* event) = 0;
    virtual void removeErrorEvent(CEvent* event) = 0;

protected:

};

}

#endif
